<template>
    <div class="scroll" v-show="flage">
       <a href="javascript:;" @click="toTop"></a>
    </div>
</template>

<script>
export default {
    props:["ofsetY"],
    data() {
        return {
            boxheight:"",
            flage:false
        }
    },
    methods:{
        scroll(){
            var that = this
           this.$parent.$el.addEventListener("scroll" , function(){
               if(this.scrollTop > 300){
                   that.flage = true
                   
               }else{
                   that.flage = false
               }
           })
        },
        toTop(){
            this.$parent.$el.scroll(0,0) 
        }
    },
   mounted(){
        this.boxheight = this.ofsetY
        this.scroll()
   }
}
</script>

<style scoped>
 .scroll{width: 49px;height: 44px; position: fixed; right: 43px; top: 50%;}
 .scroll a{display: block;width: 100%;height: 100%;background: url("../../assets/imgs/sprite.png") no-repeat;background-position: -265px -47px;}
 
</style>